Using Printing Extensions and Printer Drivers Together
While printer drivers are device dependent by definition, printing extensions can be device independent, which allows you to develop printing features that can be used with any number of devices.The printing of a document always involves exactly one or two printer drivers: the formatting driver and the output driver, as described in Inside Macintosh: QuickDraw GX Printing. In many cases, formatting and output are handled by the same printer driver. However, any number of different printing extensions can be active at the same time. For example, you could create one extension that controls a sheet feeder that can be connected to numerous printers, another extension that draws a background picture on each printed page, and another extension that prints a confidential stamp on each page. These extensions could all be active at the same time as one printer driver, as shown in Figure 1-3.
Figure 1-3 Using multiple extensions concurrently
In Figure 1-3, the confidential stamp extension adds a confidential stamp at the bottom of the page. This extension overrides the
GXSpoolPage
message and adds the shape object that represents the confidential stamp to the shapes that compose the page when the page is sent to the spool file.The background picture extension mentioned in Figure 1-3 adds a panel to the Print dialog box to allow the user to select a picture file to use. The user can choose not to have a background picture or can select a file. If the user selects a picture file, this extension overrides the
GXDespoolPage
message so that it can draw the background picture after the page has been despooled and before it has been sent to the printer. The background picture extension is described extensively in the chapter "Printing Extensions" in this book.The sheet feeder extension mentioned in Figure 1-3 works with a sheet-feeding device that can be added to laser printers produced by a number of manufacturers. This extension adds a panel to the Print dialog box to allow the user control over the sheet feeder and overrides several paper-handling messages to interface with the sheet feeder.
The laser printer driver that is mentioned in Figure 1-3 overrides a number of printing messages, including the
GXDespoolPage
message, which the background printing extension also overrides. The flow of control for theGXDespoolPage
message in this case is shown in Figure 1-4, which includes only those message handlers that override the message.Figure 1-4 Several functions handling the
GXDespoolPage
message
Whenever QuickDraw GX sends the
GXDespoolPage
message, as in this example, the following flow of control results.
One of the important issues that you have to decide when overriding a message in a printing extension or printer driver is whether to forward the message before adding your own code or after adding your own code. The timing of when your operations are performed can be critical, as is the case in the previous example. The chapter "Printing Messages" contains information about each printing message, which can help you to decide when timing might be an issue.
- The confidential stamp extension doesn't override this message, so QuickDraw GX doesn't send it to this extension.
- The background picture extension overrides
GXDespoolPage
with theBW_DespoolPage
function, which forwards the message before modifying the page.- The sheet feeder extension doesn't override this message, so QuickDraw GX doesn't forward it to this extension.
- The laser printer driver overrides
GXDespoolPage
with theLp_DespoolPage
function, which forwards the message before modifying the page.- The QuickDraw GX default implementation of
GXDespoolPage
reads the graphics and formatting data for the page.- The laser printer driver override regains control and performs its operations to restrict the page size to the size supported by the device.
- The background picture extension override regains control and performs its operations to add the background picture to the picture shape that represents the page.
Any applications that use QuickDraw GX printing features can take advantage of extensions without any coding: the user controls whether extensions are applied to the printing of documents. In the example shown in Figure 1-3, the printed output of any application that prints while the extensions are enabled will use the background picture, confidential stamp, and selected paper-feeding options.
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help